<template>
  <div class='xtx-bread'>
    <div class="xtx-bread-item">
      <RouterLink to="/">首页</RouterLink>
    </div>
    <i class="iconfont icon-angle-right"></i>
    <!-- 如果外部没有传递父级分类，那么该导航就只有：首页+一级，如果外部传递了父级分类，那么该导航就为：首页+一级+二级 -->
    <div class="xtx-bread-item" v-if="props.parentName">
      <RouterLink :to="props.parentPath">{{ props.parentName }}</RouterLink>
    </div>
    <i v-if="props.parentName" class="iconfont icon-angle-right"></i>
    <div class="xtx-bread-item">
      <!-- 当前分类的内容通过插槽传递 -->
      <span><slot></slot></span>
    </div>
  </div>
</template>

<script setup>
import { defineProps } from 'vue'
const props = defineProps({
  parentName: {
    type: String,
    default: ''
  },
  parentPath: {
    type: String,
    default: ''
  }
})
</script>

<style scoped lang='less'>
.xtx-bread {
  display: flex;
  padding: 25px 10px;

  &-item {
    a {
      color: #666;
      transition: all .4s;

      &:hover {
        color: @xtxColor;
      }
    }
  }

  i {
    font-size: 12px;
    margin-left: 5px;
    margin-right: 5px;
    line-height: 22px;
  }
}
</style>